package decorator

import (
	"fmt"
)

// 被包装的对象
type Object interface {
	MethodA()
	MethodB()
}

// 被包装对象的实现
type ConcreteObject struct{}

func (o *ConcreteObject) MethodA() {
	fmt.Println("ConcreteObject.MethodA() called.")
}

func (o *ConcreteObject) MethodB() {
	fmt.Println("ConcreteObject.MethodB() called.")
}

// 装饰者对象
type Decorator struct {
	object Object
}

func (d *Decorator) MethodA() {
	d.object.MethodA()
	fmt.Println("Decorator.MethodA() called.")
}

func (d *Decorator) MethodB() {
	d.object.MethodB()
	fmt.Println("Decorator.MethodB() called.")
}

func NewDecorator(object Object) *Decorator {
	return &Decorator{object: object}
}
